<div class="panel">
    <div class="panel_content">
        <div style="margin-bottom: 10px">
            <h2>系统管理</h2>
            <%= render :partial => "shared/back_link" %>
        </div>
        <div style="float: left; width: 49%">
            <h3>个人设置</h3>
            <% if flash[:setting_notice] %>
            <div id="notice">
                <%= flash[:setting_notice] %>
            </div>
            <br/>
            <% end %>
            <%= error_messages_for :current_user, :header_message => "保存个人设置时发生错误：", :message => nil %>
            <% form_tag('/admin/save_password', :method => :post) do %>
            <table class="form">
                <tr>
                    <th>
                        密码
                    </th>
                    <td>
                        <label class="tips" for="password">
                            请输入新密码：
                        </label>
                        <br/>
                        <%= password_field_tag "password", params[:password] %>
                        <br/>
                        <br/>
                        <label class="tips" for="password_confirmation">
                            请再次输入新密码：
                        </label>
                        <br/>
                        <%= password_field_tag "password_confirmation", params[:password_confirmation] %>
                    </td>
                </tr>
            </table>
            <br/>
            <%= submit_tag "保存密码", :disable_with => "请稍等..." %>
            <%end %>
            <br/>
            <br/>
            <br/>
            <% form_tag ('/admin/save_setting', :method => :post) do %>
            <table class="form">
                <tr>
                    <th>
                        字体
                    </th>
                    <td>
                        <label class="tips">
                            请选择字体大小：
                        </label>
                        <br/>
                        <ul class="horizontal">
                            <li>
                                <%= radio_button(:setting, "font_size", "small", :checked => @font_size == 'small') %>
                                <label for="setting_font_size_small">
                                    小字体
                                </label>
                            </li>
                            <li>
                                <%= radio_button(:setting, "font_size", "medium", :checked => @font_size == 'medium') %>
                                <label for="setting_font_size_medium">
                                    中等
                                </label>
                            </li>
                            <li>
                                <%= radio_button(:setting, "font_size", "large", :checked => @font_size == 'large') %>
                                <label for="setting_font_size_large">
                                    大字体
                                </label>
                            </li>
                        </ul>
                        <br/>
                        <br/>
                        <label class="tips">
                            请选择字体风格：
                        </label>
                        <br/>
                        <ul class="horizontal">
                            <li>
                                <%= radio_button(:setting, "font_family", "Arial, 宋体", :checked => @font_family == 'Arial, 宋体') %>
                                Arial, 宋体
                            </li>
                            <li>
                                <%= radio_button(:setting, "font_family", "Arial, 微软雅黑", :checked => @font_family == 'Arial, 微软雅黑') %>
                                Arial, 微软雅黑(需要浏览器支持)
                            </li>
                        </ul>
                    </td>
                </tr>
            </table>
            <br/>
            <%= submit_tag "保存设置", :disable_with => "请稍等..." %>
            <% end %>
        </div>
        <% if @current_user.permission == 1 %>
        <div style="margin-left: 51%;">
            <h3>用户管理</h3>
            <% if flash[:user_notice] %>
            <div class="notice">
                <%= flash[:user_notice] %>
            </div>
            <br/>
            <% end %>
            <table class="form" style="text-align: center">
                <tr>
                    <th>
                        用户名
                    </th>
                    <th>
                        帐号
                    </th>
                    <th>
                        创建时间
                    </th>
                    <th>
                        权限
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                <% for user in @users %>
                <tr>
                    <td>
                        <%= h user.name %>
                    </td>
                    <td>
                        <%= h user.username %>
                    </td>
                    <td>
                        <%= h user.created_at.strftime("%y-%m-%d %X") %>
                    </td>
                    <td>
                        <%= permission_text(user.permission) %>
                    </td>
                    <td>
                        <%= link_to '删除', { :action  => 'delete_user', :id => user },
                        :confirm => "是否删除这个用户？",
                        :method  => :delete %>
                    </td>
                </tr>
                <% end %>
            </table>
            <br/>
            添加新用户请输入：<%= error_messages_for :new_user, :header_message => "保存用户时发生错误：", :message => nil %>
            <% form_for :new_user, :url => { :action => :create_user } do |f| %>
            <table class="form">
                <tr>
                    <th>
                        <label for="new_user_name">
                            姓名
                        </label>
                    </th>
                    <td>
                        <%= f.text_field "name" %>
                    </td>
                </tr>
                <tr>
                    <th>
                        <label for="new_user_username">
                            帐号
                        </label>
                    </th>
                    <td>
                        <%= f.text_field "username" %>
                    </td>
                </tr>
                <tr>
                    <th>
                        <label for="new_user_password">
                            密码
                        </label>
                    </th>
                    <td>
                        <%= f.password_field "password" %>
                    </td>
                </tr>
                <tr>
                    <th>
                        权限
                    </th>
                    <td>
                        <ul>
                            <li>
                                <%= f.radio_button("permission", "1") %>
                                <label for="new_user_permission_1">
                                    全部
                                    <label class="tips">
                                        (可以进行任何操作，如更改收支表、维护用户数据等。)
                                    </label>
                                </label>
                            </li>
                            <li>
                                <%= f.radio_button("permission", "2") %>
                                <label for="new_user_permission_2">
                                    只读
                                    <label class="tips">
                                        (只能查看改收支表，不能更改也不能维护用户数据。)
                                    </label>
                                </label>
                            </li>
                        </ul>
                    </td>
                </tr>
            </table>
            <br/>
            <%= submit_tag "创建用户", :disable_with => "请稍等..." %>
            <%end %>
        </div>
        <% end %>
        <div style="clear: both">
        </div>
    </div>
</div>
